﻿@inject ITenantService TenantService

<p>Choose your tenant:
    <select @onchange="OnTenantChanged">
        @foreach(var tenant in TenantService.GetTenants())
        {
            <option value="@tenant" selected="@(tenant == _tenant)">@tenant</option>
        }
    </select>        
</p>

@code
{
    private string _tenant = null!;

    protected override void OnInitialized()
    {
        _tenant = TenantService.Tenant;
        base.OnInitialized();
    }

    private void OnTenantChanged(ChangeEventArgs e) =>
    TenantService.SetTenant(e.Value as string ?? _tenant);
}